<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn">点我存储</button>
    <script>
        let btn =document.querySelector('.btn');

        //设置过期时间
        // btn.onclick = function(){
        //     let d =new Date();
        //     d.setHours(new Date().getHours+1)
        //     document.cookie = `myname=hzh;expires=${d.toUTCString}`;
        // }
        //设置时间最大值，单位是秒
        btn.onclick= function(){
            document.cookie = "myname=clh;Max-Age=3600";
        }

    </script>
</body>
</html>

